package com.shop.product.service.impl;

import com.shop.common.core.utils.DateUtils;

import com.shop.common.core.web.domain.BaseEntity;
import com.shop.common.security.utils.SecurityUtils;
import com.shop.product.domain.MallProductBrandInfo;
import com.shop.product.mapper.MallProductBrandInfoMapper;
import com.shop.product.service.MallProductBrandInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MallProductBrandInfoServiceImpl implements MallProductBrandInfoService {
    @Autowired
    MallProductBrandInfoMapper mallProductBrandInfoMapper;
//    @Autowired
//    private BaseEntity getTableColumn;

    /**
     * 查询商品品牌信息列表
     * @param mallProductBrandInfo
     * @return
     */
    @Override
    public List<MallProductBrandInfo> selectMallProductBrandInfoList(MallProductBrandInfo mallProductBrandInfo)
    {
        return mallProductBrandInfoMapper.selectMallProductBrandInfoList(mallProductBrandInfo);
    }

    /**
     * 根据id查询商品品牌信息
     * @param id
     * @return
     */
    @Override
    public MallProductBrandInfo selectMallProductBrandInfoById(Long id) {

        return mallProductBrandInfoMapper.selectMallProductBrandInfoById(id);
    }

    /**
     * 添加商品品牌信息
     * @param mallProductBrandInfo
     * @return
     */
    @Override
    public int insertMallProductBrandInfo(MallProductBrandInfo mallProductBrandInfo) {
        Long userid = SecurityUtils.getLoginUser().getUserid();
        Date nowDate = DateUtils.getNowDate();

//        getTableColumn.setCreateBy(String.valueOf(userid));
//        getTableColumn.setUpdateBy(String.valueOf(userid));
        mallProductBrandInfo.setCreateBy(String.valueOf(userid));
        mallProductBrandInfo.setUpdateBy(String.valueOf(userid));
        mallProductBrandInfo.setCreateTime(nowDate);
        mallProductBrandInfo.setUpdateTime(nowDate);
        return mallProductBrandInfoMapper.insertMallProductBrandInfo(mallProductBrandInfo);
    }

    /**
     * 修改商品品牌信息
     * @param mallProductBrandInfo
     * @return
     */
    @Override
    public int updateMallProductBrandInfo(MallProductBrandInfo mallProductBrandInfo) {
        mallProductBrandInfo.setUpdateTime(DateUtils.getNowDate());
        Long userid=SecurityUtils.getLoginUser().getUserid();
        mallProductBrandInfo.setUpdateBy(String.valueOf(userid));
        return mallProductBrandInfoMapper.updateMallProductBrandInfo(mallProductBrandInfo);
    }
}
